# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

pkgbase=python-macholib
pkgname=('python2-macholib' 'python-macholib')
_pkgname=macholib
pkgver=1.16.2
pkgrel=4
pkgdesc='Mach-O header analysis and editing.'
arch=('any')
url='https://pypi.org/project/macholib/#files'
license=('MIT')
makedepends=('python2-setuptools' 'python-setuptools')
source=("https://files.pythonhosted.org/packages/source/${_pkgname::1}/$_pkgname/$_pkgname-$pkgver.tar.gz")
sha512sums=('8de00c926bb0aa3475675c75e208bd35ac3eeeee16d93fb22f63b34c34b909feb5e3ac441d7a085430fa73d29cd2a61d13a7ab9f993ae2fade36e116bdd42947')

prepare() {
  cp -a "$_pkgname-$pkgver"{,-2}
}

build() {
  cd "$_pkgname-$pkgver-2"

  python2 setup.py build

  cd "$srcdir/$_pkgname-$pkgver"

  python setup.py build
}

package_python2-macholib() {
  depends=('python2')

  cd "$_pkgname-$pkgver-2"

  python2 setup.py install --root="$pkgdir" --prefix=/usr -O1 --skip-build

  for tool in 'macho_dump' 'macho_find' 'macho_standalone'; do
    mv "$pkgdir/usr/bin/$tool" "$pkgdir/usr/bin/${tool}-2"
  done
}

package_python-macholib() {
  depends=('python')

  cd "$_pkgname-$pkgver"

  python setup.py install --root="$pkgdir" --prefix=/usr -O1 --skip-build
}

